package dao;

import hbt.HibernateUtil;
import negocio.Comanda;
import negocio.Sector;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

public class SectorDAO {

	private static SectorDAO instancia = null;
	private static SessionFactory sf = null;
	
	public SectorDAO()
	{
		
	}
	public static SectorDAO getInstancia()
	{
		if (instancia== null)
		{			
			sf = HibernateUtil.getSessionFactory();
			instancia = new SectorDAO();
		}
		return instancia;
	}

	public void grabarSector(Sector sector)
	{
		Session s = sf.openSession();
		s.beginTransaction();
		s.persist(sector);
		s.flush();
		s.getTransaction().commit();
		s.close();
	}

	public Sector buscarSector(int nroSector) {
		Session session = sf.openSession();
		Sector s = new Sector();
		s.setNroSector(nroSector); 
		session.load(s, s.getNroSector());			
		session.close();
		return s;
	}	
}
